<template>
  <view>
    <uni-segmented-control
      :current="current"
      :values="items.map((val) => val.title)"
      @clickItem="onClickItem"
      style-type="text"
      active-color="#FF69B4"
    ></uni-segmented-control>
    <view class="content">
      <view v-if="current < 4">
        <most
          :req="{ url: items[current].url, params: items[current].params }"
        ></most>
      </view>
      <view v-if="current === 4">
        <cate></cate>
      </view>
    </view>
  </view>
</template>

<script>
import { uniSegmentedControl } from "@dcloudio/uni-ui";
import Most from "components/video/Most";
import Cate from "components/video/Cate";
export default {
  components: { uniSegmentedControl, Most, Cate },
  data() {
    return {
      items: [
        {
          title: "推荐",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/featured",
          params: { limit: 30, skip: 0, order: "hot" },
        },
        {
          title: "娱乐",
          url:
            "http://157.122.54.189:9088/videoimg/v1/videowp/category/59b25abbe7bce76bc834198a",
          params: { limit: 30, skip: 0, order: "new" },
        },
        {
          title: "最新",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/videowp",
          params: { limit: 30, skip: 0, order: "new" },
        },
        {
          title: "热门",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/videowp",
          params: { limit: 30, skip: 0, order: "hot" },
        },

        {
          title: "分类",
          url: "http://157.122.54.189:9088/videoimg/v1/videowp/category",
          params: {},
        },
      ],
      current: 0,
      /* req: {
        url: this.items[this.current].url,
        params: this.items[this.current].params,
      }, */
    };
  },
  methods: {
    onClickItem(e) {
      if (this.current !== e.currentIndex) {
        this.current = e.currentIndex;
      }
    },
  },
};
</script>
<style scoped></style>
